import { PartialType } from '@nestjs/mapped-types';
import { IsNotEmpty, IsNumber, IsOptional, IsString, MinLength } from 'class-validator';
import { PagingDto } from 'src/common/dto';

export class CreateShopUserDto {
  @IsString()
  @IsNotEmpty({ message: '用户名不得为空' })
  username: string;

  @IsString()
  @MinLength(6, { message: '密码不得少于6位' })
  password: string;

  @IsOptional()
  @IsString()
  phone?: string;

  @IsOptional()
  @IsString()
  email?: string;
}

export class ListShopUsersDto extends PagingDto {
  @IsOptional()
  @IsString()
  username?: string;
}

export class UpdateShopUsersDto extends PartialType(CreateShopUserDto) {
  @IsNotEmpty({ message: 'id不得为空' })
  @IsNumber()
  id: number;
}

export class LoginDto {
  @IsNotEmpty({ message: '用户名不得为空' })
  username: string;
  @IsNotEmpty({ message: '密码不得为空' })
  @MinLength(6, { message: '密码不得少于6位' })
  password: string;
}
